import {createRouter, createWebHistory} from "vue-router";
import Index from "../components/Index.vue";
import Home from "../components/main/home/Home.vue"
import UserList from "../components/main/userManage/UserList.vue";
import IntelligentIndex from "../components/main/Intelligent/IntelligentIndex.vue";
import UserIndex from "../components/main/userManage/UserIndex.vue";
import ChartListManage from "../components/main/dataManager/ChartListManage.vue";
import Login from "../components/login/Login.vue";
import Registry from "../components/login/Registry.vue";
import UserInfo from "../components/main/userManage/UserInfo.vue";
import BackPassword from "../components/login/BackPassword.vue";

//meta元数据 title用于面包屑展示。
const routes = [
    {//一进来登录
        path: '/',
        redirect: '/login'
    },
    {//登录页
        path: '/login',
        name: 'login',
        component: Login,
    },
    {//注册页
        path: '/registry',
        name: 'registry',
        component: Registry,
    },
    {//找回密码
        path: '/backPassword',
        name: 'backPassword',
        component: BackPassword,
    },
    {//主体框架
        path: '/index',
        name: 'index',
        component: Index,
        meta: {title: '首页'},
        redirect: '/home', //默认组件展示，切到index组件的时候，就去显示地址为/home的组件
        children: [ //子路由 点击左侧导航栏跳转到指定子路由
            {//首页
                path: '/home',
                component: Home,
                name: 'home',
                meta: {title: '首页'},
            },
            {//信息管理页路由
                path: '/IntelligentIndex',
                component: IntelligentIndex,
                name: 'intelligentIndex',
                meta: {title: 'AI聊天'},
            },
            {
                path: '/ChatListIndex',
                component: ChartListManage,
                name: 'ChatListIndex',
                meta: {title: '消息列表'}
            },
            {//用户管理页路由
                path: "/userIndex",
                component: UserIndex,
                name: "userIndex",
                meta: {title: '用户中心'},
                redirect: "/userIndex/userList",
                children: [
                    {
                        //用户管理页
                        path: "/userIndex/userList",
                        name: 'userList',
                        component: UserList,
                        meta: {title: '用户列表'},
                    }
                    ,
                    {
                        //用户展示页
                        path: "/userIndex/userInfo",
                        name: 'userInfo',
                        component: UserInfo,
                        meta: {title: '用户设置'},
                    }
                ]
            }
        ]
    },
]



const router = createRouter({
    // history: createWebHashHistory(),
    history: createWebHistory(),
    routes,
});

export default router;
